<form action="<?php echo BASE_URL;?>/test/gradingtest" method="post" id="test-form">

<input type="hidden" name="test_id" id="test_id" value="<?php echo $this->test_id;?>">

<script type="text/javascript" language="javascript">
<!--
$(document).ready(function(){
	$(".question-container-div").hide()
	$(".separator-question-test").hide()
	var question_per_page = $(".question_per_page").val();
	showPage(0,question_per_page);
	$(".focus-page-test").eq(0).addClass("focus-page-test-active");
});
function focusPage(up_or_down,currentPage){
	page_obj  = $(".focus-page-test-"+up_or_down);
	page_obj.removeClass("focus-page-test-active");
	page_obj.eq(currentPage).addClass("focus-page-test-active");
}
function showPage(currentPage, questionPerpage)
{
	focusPage(1,currentPage);
	focusPage(2,currentPage);
	$(".question-container-div").hide()
	$(".separator-question-test").hide()
	var start  	= currentPage*questionPerpage;
	var end		= start+questionPerpage;
	for(i=start; i< end; i++){
		$(".separator-question-test").eq(i).show();
		$(".question-container-div").eq(i).show();
	}
}
//-->
</script>

<?php		

	$test_id = $this->test_id;
	if(!empty($test_id)){
		
		$models_test = new Default_Models_Test();
		$models_test->find("id",$test_id);
		if($models_test->getId()){
			$list_questionID 	= explode(',', $models_test->getList_question());
			$list_score    		= explode(',',$models_test->getList_score());
			$questionPerPage	= $models_test->getQuestion_perpage();
			$questionPerPage 	= $questionPerPage==0? 1:$questionPerPage;
			$totalQuestion		= count($list_questionID);
			$totalPage			= (int)($totalQuestion/$questionPerPage);
			$totalPage			= $totalQuestion%$questionPerPage==0?$totalPage:($totalPage+1) ;
			var_dump($totalQuestion);
			var_dump($totalPage);
			$link = "<div class='page_review_test'>";
			for($i=0;$i<$totalPage;$i++)
				$link .= "&nbsp;<a href='#' onclick='showPage($i,$questionPerPage); return false;'><span class='focus-page-test-1'> ".($i+1)."</span></a> &nbsp;&nbsp;";
			echo $link;
			if(!empty($list_questionID[0])){		
					foreach($list_questionID as $key=>$list_questionIDItem){ 
							echo  $this->viewQuestion($this->test_id,$list_questionIDItem,"Câu ".($key+1)." : ",array(),0,0,0,1,-1,$list_score[$key] );
							echo "<span class='separator-question-test'><hr/></span>";
					}
			$link .="</div>";
			$link = "<div class='page_review_test'>";
			for($i=0;$i<$totalPage;$i++)
				$link .= "&nbsp;<a href='#' onclick='showPage($i,$questionPerPage); return false;'><span class='focus-page-test-2'> ".($i+1)."</span></a> &nbsp;&nbsp;";			
				$link .="</div>";
			echo $link;
			}
?>			
			<input type="hidden" class="question_per_page" value="<?php echo $questionPerPage; ?>">
			<input type="submit" value="Gửi kết quả bài thi">
		 	<input type="button" value="Nộp bài và kết thúc">
<?php  		 
		} 
	
	}else{ 
			echo "<p> Test id is null</p>";
 	} ?>

</form>
<hr/>
